//! Tickles.debug.js
//

(function() {

Type.registerNamespace('Tickles');

////////////////////////////////////////////////////////////////////////////////
// Gig

Gig = function Gig() {
    Gig.initializeBase(this);
    this.element = $("<div class='Tickle'/>");
}
Gig.restoreAw = function Gig$restoreAw(awp, partitionKey, rowKey) {
    /// <param name="awp" type="Await">
    /// </param>
    /// <param name="partitionKey" type="String">
    /// </param>
    /// <param name="rowKey" type="String">
    /// </param>
    new Await().addAw(FileBlobBase.retrieveBlobStringAw, partitionKey, rowKey).handleDl(Exceptions.blobLoadError, Await.rethrowAw).addDx(function(aw) {
        var raw = aw.get_item(PkgBase.resultRx);
        var td = JSON.parse(raw);
        Gig.injectIntoPage(td);
    }).commit(awp);
}
Gig.injectIntoPage = function Gig$injectIntoPage(td) {
    /// <param name="td" type="Tickles.TickleData">
    /// </param>
    /// <returns type="Gig"></returns>
    var tt = new Gig();
    var where = $(td.selecTo);
    if (!!where.length) {
        tt.element = $(td.html);
        tt.appendTo(where);
    }
    else {
        throw new Error(Exceptions.format(Exceptions.missingDomElement, Exceptions.fn(arguments)));
    }
    return tt;
}
Gig.prototype = {
    
    get_data: function Gig$get_data() {
        /// <value type="Tickles.TickleData"></value>
        return this.scoop(this.element);
    },
    
    scoop: function Gig$scoop(el) {
        /// <param name="el" type="jQueryObject">
        /// </param>
        /// <returns type="Tickles.TickleData"></returns>
        var td = new Tickles.TickleData();
        td.pos = el.position();
        td.off = el.offset();
        td.dim = new Tickles.Dimension();
        td.dim.width = el.width();
        td.dim.height = el.height();
        td.selecTo = el.selecTo({ parent: true });
        td.html = el[0].outerHMTL;
        return td;
    },
    
    _serialize$3: function Gig$_serialize$3() {
        /// <returns type="String"></returns>
        return JSON.stringify(this.get_data());
    },
    
    saveAw: function Gig$saveAw(awp, partitionKey, rowKey) {
        /// <param name="awp" type="Await">
        /// </param>
        /// <param name="partitionKey" type="String">
        /// </param>
        /// <param name="rowKey" type="String">
        /// </param>
        FileBlobBase.storeBlobStringAw(awp, partitionKey, rowKey, this._serialize$3());
    },
    
    appendTo: function Gig$appendTo(el) {
        /// <param name="el" type="jQueryObject">
        /// </param>
        /// <returns type="Gig"></returns>
        this.element.appendTo(el);
        return this;
    },
    
    fromHtml: function Gig$fromHtml(html) {
        /// <param name="html" type="String">
        /// </param>
        /// <returns type="Gig"></returns>
        $(html).appendTo(this.element);
        return this;
    }
}


////////////////////////////////////////////////////////////////////////////////
// Tickles.TickleData

Tickles.TickleData = function Tickles_TickleData() {
    /// <field name="dim" type="Tickles.Dimension">
    /// </field>
    /// <field name="html" type="String">
    /// </field>
    /// <field name="off" type="jQueryPosition">
    /// </field>
    /// <field name="pos" type="jQueryPosition">
    /// </field>
    /// <field name="selecTo" type="String">
    /// </field>
}
Tickles.TickleData.prototype = {
    dim: null,
    html: null,
    off: null,
    pos: null,
    selecTo: null
}


////////////////////////////////////////////////////////////////////////////////
// Tickles.Dimension

Tickles.Dimension = function Tickles_Dimension() {
    /// <field name="height" type="Number" integer="true">
    /// </field>
    /// <field name="width" type="Number" integer="true">
    /// </field>
}
Tickles.Dimension.prototype = {
    height: 0,
    width: 0
}


Gig.registerClass('Gig', Actor);
Tickles.TickleData.registerClass('Tickles.TickleData');
Tickles.Dimension.registerClass('Tickles.Dimension');
})();

//! This script was generated using Script# v0.7.4.0
